#ifndef __SHM_H__ 
#define __SHM_H__


#include "CommonHeader.h"


enum QMode
{
    eUnknown,
    eWriter,
    eReader,
    eBoth,
};

/*

Shm is responsible for opening and closing shm storage

*/
class Shm
{
public:

    Shm();

    ~Shm();
      
    //restore data from last state and init the stor
    bool init(const char *,QMode = eWriter );
    //close file handlers and finish memory maping
    void close();

    HANDLE OpenOrCreateFile(const char*);

private:

    bool OpenMappedFileWriter(const char*);

    bool OpenMappedFileReader(const char*);

    Shm(const Shm&);

    Shm operator = (const Shm&);

    //file name =>path
    char* 		m_pcFileName;

    //memory mapped file handle
    HANDLE		m_hMapFile;

    
    //Hard dsik file handle
    HANDLE		m_hFile;
    //entry count

    // mode of operation
    QMode       m_eMode;

    //int         m_nElemCount;
protected:
    //mapped address start
    void* 		m_pBuf;

    // allocation start for mapped address
    void* 	  	m_pBufAllocation;
};
#endif //__SHM_H__
